package com.jy.appmarket.activity;

import com.jy.appmarket.R;
import com.umeng.fb.fragment.FeedbackFragment;

import android.app.ActionBar;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.MenuItem;

public class UmengFeedbackActivity extends FragmentActivity {

	private FeedbackFragment mFeedbackFragment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_umeng_feedback);

		initTitle();
		if (savedInstanceState == null) {
			String conversation_id = getIntent().getStringExtra(
					FeedbackFragment.BUNDLE_KEY_CONVERSATION_ID);
			mFeedbackFragment = FeedbackFragment.newInstance(conversation_id);

			getSupportFragmentManager().beginTransaction()
					.add(R.id.container, mFeedbackFragment).commit();
		}
	}

	private void initTitle() {
		ActionBar actionBar = getActionBar();
		actionBar.setTitle("用户反馈");
		actionBar.setDisplayUseLogoEnabled(false);
		actionBar.setDisplayShowHomeEnabled(false);
		actionBar.setDisplayHomeAsUpEnabled(true);
	}

	@Override
	protected void onNewIntent(android.content.Intent intent) {
		mFeedbackFragment.refresh();
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

}
